(function() {
  function getAnonymousState(location)
  {
    var a = location.search.split('?');
    var params = [];
    if (a[1]) {
      params = a[1].split('&');
    }

    var newParams = [];
    for (var i = 0; i < params.length; i++) {
      if (!params[i].match(/^ea(\.campaigner|_broadcast|\.url)/))
        newParams.push(params[i]);
    }

    var newState = location.pathname;
    if (newParams.length > 0)
      newState += '?' + newParams.join('&');

    return newState;
  }

  if (history.replaceState) history.replaceState(null, '', getAnonymousState(location));})();
